﻿Public Class ActualizarClientes
    Inherits System.Web.UI.Page
    Dim c As New Conexion
    Dim id As Integer = 0

    Public nombres As String = ""

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("VariableNombre") = Nothing Then
            Label1.Text = "Tienes que Logearte"
            btnLogout.Visible = False
        Else
            HyperLink1.Visible = False
            Label2.Text = "Bienvenido " + Session("VariableNombre").ToString()

            c.SeleccionarLetras(TextBox6, "select nombres from usuarios where login='" & Session("VariableNombre").ToString() & "'")
            Label2.Text = "Bienvenido " + TextBox6.Text


        End If
    End Sub

    Protected Sub btnLogout_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogout.Click
        Session("VariableNombre") = Nothing
        Response.Redirect("InicioSesion.aspx")
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim nombres2 As String = DropDownList1.SelectedItem.Text

        c.Seleccionar(TextBox7, "select idcliente from clientes where nombres_cliente='" & nombres2 & "'")
        id = Convert.ToInt32(TextBox7.Text)

        Dim nombres As String = TextBox1.Text
        Dim direccion As String = TextBox2.Text
        Dim telefono As String = TextBox3.Text
        Dim celular As String = TextBox4.Text
        Dim sentencia As String = "update clientes set nombres_cliente='" & nombres & "', direccion_cliente='" & direccion & "', telefonocliente='" & telefono & "', celularcliente='" & celular & "' where idcliente=" & id
        c.Insertar_Actualizar_Eliminar(sentencia, "actualizados")
        Label1.Text = Conexion.msj_sql_server
    End Sub

    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DropDownList1.SelectedIndexChanged
        Try
            nombres = DropDownList1.SelectedItem.Text()


            c.Seleccionar(TextBox7, "select idcliente from clientes where nombres_cliente='" & nombres & "'")
            id = Convert.ToInt32(TextBox7.Text)

            c.SeleccionarLetras(TextBox1, "select nombres_cliente from clientes where idcliente=" & id & "")
            c.SeleccionarLetras(TextBox2, "select direccion_cliente from clientes where idcliente=" & id & "")
            c.SeleccionarLetras(TextBox3, "select telefonocliente from clientes where idcliente=" & id & "")
            c.SeleccionarLetras(TextBox4, "select celularcliente from clientes where idcliente=" & id & "")
        Catch ex As Exception
            MsgBox(ex.ToString)

        End Try
    End Sub

    Protected Sub TextBox7_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox7.TextChanged

    End Sub
End Class